<template>
  <div>
    <el-row style="margin-top: 10px;">
      <el-col :span="6" :offset="6">
       <el-input v-model="pawnShop.shopName" placeholder="请输入门店名称"></el-input>
      </el-col>
    </el-row>
    <el-row style="margin-top: 10px;">
      <el-col :span="6" :offset="6">
      <el-input v-model="pawnShop.shopPhone" placeholder="绑定门店联系电话"></el-input>
      </el-col>
    </el-row>
    <el-row style="margin-top: 10px;">
      <el-col :span="6" :offset="6">
      <el-input v-model="pawnShop.address" placeholder="请输入门店地址"></el-input>
      </el-col>
    </el-row>
    <el-row style="margin-top: 10px;">
      <el-col :span="6" :offset="6">
      <el-select v-model="pawnShop.shopBossId" placeholder="请选择店长">
        <el-option
            v-for="item in shopBoss"
            :key="item.accountId"
            :label="item.realName"
            :value="item.accountId">
          </el-option>
        </el-select>
      </el-col>
    </el-row>
    <el-row style="margin-top: 50px;">
      <el-col :span="2" :offset="6">
        <el-button type="warning" @click="canel">重置</el-button>
      </el-col>
      <el-col :span="2" :offset="1">
        <el-button type="success" @click="addShop">新增门店</el-button>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  export default{
    name:"AddShop",
    data(){
      return{
      shopBoss:[],//未绑定店长Id
      pawnShop:{} //新增门店参数
      }
    },
    methods:{
      //重置
      canel(){
       this.pawnShop={}
      },
      //新增门店
      addShop(){
       this.$http.post("/admin/pawnShop/insertPawnShop",this.pawnShop).then(resp=>{
         if(resp.data.code==200){
           this.$message({
                     message: '添加门店成功',
                     type: 'success'
                   });
         }else{
            this.$message.error(resp.data.message);
         }
         this.pawnShop={}
         this.selectAllShopBoss()
       })
      },
      //查询未绑定店长
    selectAllShopBoss(){
      this.$http.get("admin/adminInfo/selectAllShopBoss").then(resp=>{
       this.shopBoss=resp.data.data
      })
    }
    },
    created(){
    this.selectAllShopBoss()
    }
  }
</script>

<style>
</style>
